package com.coocaa.optimizer.bugreport;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.HandlerThread;

public class DropBoxReceiver extends BroadcastReceiver {
    private static HandlerThread ht = null;
    private static Handler handler = null;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (ht == null) {
            ht = new HandlerThread("BugReport");
            ht.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
                @Override
                public void uncaughtException(Thread thread, Throwable ex) {
                    ex.printStackTrace();
                }
            });
            ht.start();
        }
        if (handler == null)
            handler = new Handler(ht.getLooper());
        handler.post(new BugReport(context, intent));
    }
}
